(global.webpackJsonp = global.webpackJsonp || []).push([ [ "wjyk_recycle/pages/transaction/index/buy/buy" ], {
    1439: function(e, t, r) {
        (function(e) {
            function t(e) {
                return e && e.__esModule ? e : {
                    default: e
                };
            }
            r("8163"), t(r("66fd")), e(t(r("2440")).default);
        }).call(this, r("543d").createPage);
    },
    2440: function(e, t, r) {
        r.r(t);
        var n, a = r("3748"), s = r("d828");
        for (n in s) "default" !== n && function(e) {
            r.d(t, e, function() {
                return s[e];
            });
        }(n);
        r("a89a");
        var i = r("f0c5"), a = Object(i.a)(s.default, a.b, a.c, !1, null, null, null, !1, a.a, void 0);
        t.default = a.exports;
    },
    "31cc": function(e, t, r) {},
    3748: function(e, t, r) {
        function n() {
            this.$createElement, this._self._c;
        }
        var a = {
            sunuiPopup: function() {
                return r.e("components/sunui-popup/sunui-popup").then(r.bind(null, "c2fe"));
            }
        }, s = [];
        r.d(t, "b", function() {
            return n;
        }), r.d(t, "c", function() {
            return s;
        }), r.d(t, "a", function() {
            return a;
        });
    },
    a89a: function(e, t, r) {
        var n = r("31cc");
        r.n(n).a;
    },
    c7ed: function(e, r, n) {
        (function(a) {
            Object.defineProperty(r, "__esModule", {
                value: !0
            }), r.default = void 0;
            var s = e(n("4795")), i = e(n("5438"));
            function e(e) {
                return e && e.__esModule ? e : {
                    default: e
                };
            }
            function o(e, t, r, n, a, s, i) {
                try {
                    var u = e[s](i), o = u.value;
                } catch (e) {
                    return r(e), 0;
                }
                u.done ? t(o) : Promise.resolve(o).then(n, a);
            }
            function u(u) {
                return function() {
                    var e = this, i = arguments;
                    return new Promise(function(t, r) {
                        var n = u.apply(e, i);
                        function a(e) {
                            o(n, t, r, a, s, "next", e);
                        }
                        function s(e) {
                            o(n, t, r, a, s, "throw", e);
                        }
                        a(void 0);
                    });
                };
            }
            var t = {
                data: function() {
                    return {
                        recycle: a.getStorageSync("name"),
                        sid: "",
                        type: "",
                        idealPrice: "",
                        obj: {},
                        charge: "",
                        addressflag: !0,
                        addressInfo: {},
                        addressid: "",
                        partner_id: "",
                        userObj: {},
                        money: 0,
                        isPay: !1
                    };
                },
                onLoad: function(e) {
                    this.sid = e.sid, this.type = e.type, 1 == this.type && a.setNavigationBarTitle({
                        title: "下单中"
                    }), 2 == this.type && a.setNavigationBarTitle({
                        title: "议价下单"
                    });
                },
                onShow: function() {
                    i.default.releaseKey("subOrder"), this.getDetail(), this.getDefault(), this.getCharge(), 
                    this.user();
                },
                methods: {
                    close: function() {
                        this.$refs.pop.close();
                    },
                    openPop: function() {
                        var e;
                        Number(this.userObj.balance) < Number(this.obj.price) ? (this.isPay = !0, e = Number(Number(this.obj.price) - Number(this.userObj.balance)).toFixed(2), 
                        this.money = Number(Number(e) / Number(this.charge)).toFixed(2), console.log(this.money)) : this.isPay = !1, 
                        this.$refs.pop.show({
                            style: "background-color:#fff;width:504rpx;height:auth;border-radius:10rpx;"
                        });
                    },
                    user: function() {
                        var r = this;
                        return u(s.default.mark(function e() {
                            var t;
                            return s.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    return e.next = 2, r.$http({
                                        url: r.$api.user,
                                        data: {
                                            uid: a.getStorageSync("uid")
                                        }
                                    });

                                  case 2:
                                    0 == (t = e.sent).errno && (r.userObj = t.data);

                                  case 4:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    },
                    subOrder: function() {
                        this.close(), this.addressid ? this.idealPrice ? this.createOrder(1) : this.$sun.toast("请输入理想价格!") : this.$sun.toast("请选择收货地址!");
                    },
                    recycleOrder: function() {
                        this.close(), this.addressid ? this.isPay ? this.wxPay(2) : this.createOrder(2) : this.$sun.toast("请选择收货地址!");
                    },
                    wxPay: function(r) {
                        var n = this;
                        return u(s.default.mark(function e() {
                            var t;
                            return s.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    return e.next = 2, n.$http({
                                        url: n.$api.pay,
                                        show: !0,
                                        method: "post",
                                        data: {
                                            openid: a.getStorageSync("openid"),
                                            money: n.money
                                        }
                                    });

                                  case 2:
                                    0 == (t = e.sent).errno && a.requestPayment({
                                        provider: "wxpay",
                                        timeStamp: t.data.timeStamp,
                                        nonceStr: t.data.nonceStr,
                                        package: t.data.package,
                                        signType: t.data.signType,
                                        paySign: t.data.paySign,
                                        success: function() {
                                            var t = u(s.default.mark(function e(t) {
                                                return s.default.wrap(function(e) {
                                                    for (;;) switch (e.prev = e.next) {
                                                      case 0:
                                                        n.createOrder(r);

                                                      case 1:
                                                      case "end":
                                                        return e.stop();
                                                    }
                                                }, e);
                                            }));
                                            return function(e) {
                                                return t.apply(this, arguments);
                                            };
                                        }(),
                                        fail: function(e) {
                                            console.log(JSON.stringify(e)), n.$sun.toast("取消支付");
                                        }
                                    });

                                  case 4:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    },
                    createOrder: function(r) {
                        var e, n = this;
                        i.default.uniDoFunc({
                            key: "subOrder",
                            success: (e = u(s.default.mark(function e() {
                                var t;
                                return s.default.wrap(function(e) {
                                    for (;;) switch (e.prev = e.next) {
                                      case 0:
                                        return e.next = 2, n.$http({
                                            url: n.$api.tAddOrder,
                                            data: {
                                                purchaser: a.getStorageSync("uid"),
                                                goodsid: n.sid,
                                                type: n.type,
                                                addressid: n.addressInfo.id,
                                                partner_id: n.addressInfo.flag,
                                                ideal_price: n.idealPrice,
                                                price: 1 == n.type ? n.money : 0,
                                                integral: 1 == n.type ? n.isPay ? n.userObj.balance : n.obj.price : 0
                                            }
                                        });

                                      case 2:
                                        0 == (t = e.sent).errno ? (a.showToast({
                                            title: t.message,
                                            duration: 1500
                                        }), setTimeout(function() {
                                            a.navigateTo({
                                                url: "/wjyk_recycle/pages/transaction/my/order/order?selIndex=" + r
                                            });
                                        }, 1500)) : (n.$sun.toast(t.message), i.default.releaseKey("subOrder")), console.log("防抖... 在事件触发前连续点击事件会重新计时");

                                      case 5:
                                      case "end":
                                        return e.stop();
                                    }
                                }, e);
                            })), function() {
                                return e.apply(this, arguments);
                            })
                        });
                    },
                    getCharge: function() {
                        var r = this;
                        return u(s.default.mark(function e() {
                            var t;
                            return s.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    return e.next = 2, r.$http({
                                        url: r.$api.transactions
                                    });

                                  case 2:
                                    0 == (t = e.sent).errno && (r.charge = t.data.set.charge);

                                  case 4:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    },
                    selectAddress: function() {
                        a.setStorageSync("addressName", "buy"), a.navigateTo({
                            url: "/wjyk_recycle/pages/address/address"
                        });
                    },
                    getDefault: function() {
                        var r = this;
                        return u(s.default.mark(function e() {
                            var t;
                            return s.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    return e.next = 2, r.$http({
                                        url: r.$api.getDefault,
                                        data: {
                                            uid: a.getStorageSync("uid")
                                        }
                                    });

                                  case 2:
                                    0 == (t = e.sent).errno && (0 == t.data.length ? r.addressflag = !0 : (r.addressflag = !1, 
                                    r.addressInfo = t.data, r.addressid = t.data.id, r.partner_id = t.data.flag));

                                  case 4:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    },
                    getDetail: function() {
                        var r = this;
                        return u(s.default.mark(function e() {
                            var t;
                            return s.default.wrap(function(e) {
                                for (;;) switch (e.prev = e.next) {
                                  case 0:
                                    return e.next = 2, r.$http({
                                        url: r.$api.tGoodsDetail,
                                        data: {
                                            goodsid: r.sid
                                        }
                                    });

                                  case 2:
                                    0 == (t = e.sent).errno && (r.obj = t.data);

                                  case 4:
                                  case "end":
                                    return e.stop();
                                }
                            }, e);
                        }))();
                    }
                }
            };
            r.default = t;
        }).call(this, n("543d").default);
    },
    d828: function(e, t, r) {
        r.r(t);
        var n, a = r("c7ed"), s = r.n(a);
        for (n in a) "default" !== n && function(e) {
            r.d(t, e, function() {
                return a[e];
            });
        }(n);
        t.default = s.a;
    }
}, [ [ "1439", "common/runtime", "common/vendor" ] ] ]);